import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '合同产品ID',
    align:"center",
    dataIndex: 'wmItemId'
   },
   {
    title: '任务书名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '任务书编码',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '负责人',
    align:"center",
    dataIndex: 'chargeBy_dictText'
   },
   {
    title: '进度',
    align:"center",
    dataIndex: 'progress'
   },
   {
    title: '联系人',
    align:"center",
    dataIndex: 'contactPerson'
   },
   {
    title: '附件',
    align:"center",
    dataIndex: 'file',
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'status_dictText'
   },
   {
    title: '当前节点ID',
    align:"center",
    dataIndex: 'currentNodeId'
   },
   {
    title: '计划开始时间',
    align:"center",
    dataIndex: 'planBeginTime'
   },
   {
    title: '计划完成时间',
    align:"center",
    dataIndex: 'planEndTime'
   },
   {
    title: '实际开始时间',
    align:"center",
    dataIndex: 'factBeginTime'
   },
   {
    title: '实际完成时间',
    align:"center",
    dataIndex: 'factEndTime'
   },
   {
    title: '权重',
    align:"center",
    dataIndex: 'weight'
   },
   {
    title: '是否含调试',
    align:"center",
    dataIndex: 'includeDebug',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}])
     },
   },
   {
    title: '事业部ID',
    align:"center",
    dataIndex: 'buId_dictText'
   },
   {
    title: '供应商ID',
    align:"center",
    dataIndex: 'wmVendorId_dictText'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '合同产品ID',
    field: 'wmItemId',
    component: 'Input',
  },
  {
    label: '任务书名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入任务书名称!'},
          ];
     },
  },
  {
    label: '任务书编码',
    field: 'code',
    component: 'Input',
  },
  {
    label: '负责人',
    field: 'chargeBy',
    component: 'JSelectUser',
    componentProps:{
    },
  },
  {
    label: '联系人',
    field: 'contactPerson',
    component: 'Input',
  },
  {
    label: '附件',
    field: 'file',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '计划开始时间',
    field: 'planBeginTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '计划完成时间',
    field: 'planEndTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '权重',
    field: 'weight',
    component: 'Input',
  },
  {
    label: '是否含调试',
    field: 'includeDebug',
    defaultValue: 0,
     component: 'JSwitch',
     componentProps:{
     },
  },
  {
    label: '事业部ID',
    field: 'buId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"sys_depart,depart_name,id"
     },
  },
  {
    label: '任务书流程ID',
    field: 'wmTaskbookFlowId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"wm_taskbook_flow,name,id"
     },
  },
  {
    label: '供应商ID',
    field: 'wmVendorId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"wm_vendor,cn_name,id"
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  wmItemId: {title: '合同产品ID',order: 0,view: 'text', type: 'string',},
  name: {title: '任务书名称',order: 1,view: 'text', type: 'string',},
  code: {title: '任务书编码',order: 2,view: 'text', type: 'string',},
  chargeBy: {title: '负责人',order: 3,view: 'sel_user', type: 'string',},
  progress: {title: '进度',order: 4,view: 'text', type: 'string',},
  contactPerson: {title: '联系人',order: 5,view: 'text', type: 'string',},
  file: {title: '附件',order: 6,view: 'file', type: 'string',},
  status: {title: '状态',order: 7,view: 'list', type: 'string',dictCode: 'taskbook_status',},
  currentNodeId: {title: '当前节点ID',order: 8,view: 'text', type: 'string',},
  planBeginTime: {title: '计划开始时间',order: 9,view: 'datetime', type: 'string',},
  planEndTime: {title: '计划完成时间',order: 10,view: 'datetime', type: 'string',},
  factBeginTime: {title: '实际开始时间',order: 11,view: 'datetime', type: 'string',},
  factEndTime: {title: '实际完成时间',order: 12,view: 'datetime', type: 'string',},
  weight: {title: '权重',order: 13,view: 'text', type: 'string',},
  includeDebug: {title: '是否含调试',order: 14,view: 'number', type: 'number',},
  buId: {title: '事业部ID',order: 15,view: 'list', type: 'string',dictTable: "sys_depart", dictCode: 'id', dictText: 'depart_name',},
  wmVendorId: {title: '供应商ID',order: 17,view: 'list', type: 'string',dictTable: "wm_vendor", dictCode: 'id', dictText: 'cn_name',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}